import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';


class MyLoading{
 static int _loadingCount=0;

 static init(){
    //定义loading样式
    EasyLoading.instance
      ..indicatorType = EasyLoadingIndicatorType.fadingCircle
      ..maskType=EasyLoadingMaskType.black
      // ..loadingStyle = EasyLoadingStyle.light
      ..loadingStyle = EasyLoadingStyle.dark
      ..maskColor = Colors.blue.withOpacity(0.5)
      ..userInteractions = false;
  }

 static void show(){
    if (_loadingCount==0) {
      EasyLoading.show(status: 'loading...');
    }
    _loadingCount++;
  }
 static void dismiss(){
    if (_loadingCount==0) {
      return;
    }
    _loadingCount--;
    if (_loadingCount==0) {
      EasyLoading.dismiss();
    }
  }
}